#include "ioc.h"

cJSON *cjson_humTem()
{
    cJSON *obj = cJSON_CreateObject();
    cJSON_AddNumberToObject(obj, "tem", temp_read());
    cJSON_AddNumberToObject(obj, "hum", hum_read());
    cJSON_AddNumberToObject(obj, "id", 0);
    return obj;
}
cJSON *cjson_buzzer()
{
    cJSON *obj = cJSON_CreateObject();
    cJSON_AddBoolToObject(obj, "buzzer", BUZZER_STATE);
    cJSON_AddNumberToObject(obj, "id", 0);
    return obj;
}
cJSON *cjosn_fan()
{
    cJSON *obj = cJSON_CreateObject();
    cJSON_AddBoolToObject(obj, "fan", FAN_STATE);
    cJSON_AddNumberToObject(obj, "id", 0);
    return obj;
}
cJSON *cjson_lamp(int LED_ID, char *led)
{
    char *msg = read_file(led);
    int led_status = atoi(msg);
    cJSON *obj = cJSON_CreateObject();
    cJSON_AddBoolToObject(obj, "lamp", led_status);
    cJSON_AddNumberToObject(obj, "id", LED_ID);
    return obj;
}
